<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
class Eyeworx_Inventory_LensImportInstall extends ModuleInstall
{

    public function install()
    {
        try {
            $type = array(
                'single' => 'Single Vision/Bifocal',
                'double' => 'Double Vision/Multifocal',
                'prog' => 'Progressive',
                'asph' => 'Aspheric'
            );
            Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Lens/type', $type);

            $material = array(
                'cr39' => 'Glass',
                'plastic' => 'Plastic Lens',
                'poly' => 'Polycarbonates',
                'trans' => 'Transitional'
            );
            Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Lens/material', $material);

            $lens_recordset = new Eyeworx_Inventory_Lens_RBO_RBOLenses();
            $lens_recordset->install();
            $lens_recordset->register_processing_callback(array('Eyeworx_Inventory_LensImportCommon', 'submit_lens'));
            $lens_recordset->add_default_access();
            $lens_recordset->set_caption('Lens');
        } catch (Exception $e) {
            return false;
        }
        return true;
    }

    public function uninstall()
    {
        try {
            $lens_recordset = new Eyeworx_Inventory_Lens_RBO_RBOLenses();
            $lens_recordset->uninstall();

            Utils_CommonDataCommon::remove('Eyeworx/Inventory/Lens/type');
            Utils_CommonDataCommon::remove('Eyeworx/Inventory/Lens/material');
        } catch (Exception $e) {
            return false;
        }
        return true;
    }

    public function requires($v)
    {
        return array(
            array('name' => 'Base/Lang', 'version' => 0),
            array('name' => 'Utils/RecordBrowser', 'version' => 0),
        );
    }

    public function info()
    {
        return array(
            'Author' => 'Pauline Joy Garcia',
            'Description' => 'Email: paulinejoygarcia@gmail.com'
        );
    }

    public function version()
    {
        return array('1.0');
    }

    public function simple_setup()
    {
        return array('package' => __('Eyeworx'), 'option' => __('Lens Import'));
    }

}

?>